package com.itheima.app.controller;


import com.itheima.app.exception.BusinessException;
import com.itheima.app.manager.VoiceManager;
import com.itheima.vo.VoiceVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
public class VoiceController {

    @Autowired
    private VoiceManager voiceManager;

    // 桃花传音
    // 发送语音
    @PostMapping("/peachblossom")
    public void sendVoice(MultipartFile soundFile) throws IOException {

        // 调用manager保存语音
        voiceManager.sendVoice(soundFile);
    }

    // 接收语音
    @GetMapping("/peachblossom")
    public VoiceVo findVoice() {

        // 直接调用manager查询语音
        VoiceVo voiceVo = voiceManager.findVoice();

        return voiceVo;
    }
}
